package com.fish.manni;

import javax.swing.JFrame;
import java.awt.*;
import javax.swing.JLabel;
import javax.swing.ImageIcon;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
 
 
public class Csdnblog extends JFrame{
    public static void main(String args[]) {
        Csdnblog test = new Csdnblog();
        test.GameHome();
    }
 
 
        //启动窗体
        public void GameHome(){
            JFrame jframe = new JFrame();   //构造JFrame对象
//        jframe.setLayout(new FlowLayout());
            Container container = jframe.getContentPane();  //在窗体中添加一个面板操作，
            jframe.setSize(800,600);    //设置窗体长宽为200 200
            jframe.setTitle("TankWar Version 0.1");     //设置窗体标题
//        jframe.setVisible(true);    //设置窗体可见
            jframe.show();  //设置窗体可见
            jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  //关闭功能
            jframe.setLocationRelativeTo(null);     //设置打开GUI时在屏幕中间
            container.setBackground(Color.black);   //设置背景色为黑色
 
            //添加“Tank2010”图片
            ImageIcon imageicon = new ImageIcon("Pic/BackGround/BackGround.png");   //将背景图片的地址传递给imageicon
            JLabel jlabel = new JLabel(imageicon);  //将imageicon设置成JLabel控件
            jframe.add(jlabel);     //将控件添加到窗口中
            jlabel.setBounds(0,0,800,200);  //设置图片的x、y坐标、宽、高度
            //版权信息
 
 
            JLabel copyright = new JLabel("Copyright ZhongJQing ©2015-2020");
            jframe.add(copyright);  //将版权信息添加到窗口中
            JLabel copyright1 = new JLabel("Test TankWar Version 0.1 By ZhongJQing");
            jframe.add(copyright1);
//        copyright1.setFont(new Font("宋体",1,20));
            copyright.setBounds(250,500,400,20);   //设置文字的x、y坐标和宽度、高度
            copyright1.setBounds(250,520,500,20);
            copyright.setForeground(Color.white);
            copyright1.setForeground(Color.white);
 
//            addKeyListener(new KeyboardListener());
//            copyright.addKeyListener(new KeyboardListener());
            jframe.addKeyListener(new KeyboardListener());
        }
        
        //加入键盘监听器
        class KeyboardListener extends KeyAdapter{
            public void keyPressed(KeyEvent e){
                Csdnblog.Go(e);
            }
        }
        static void Go(KeyEvent e){
        switch(e.getKeyCode()){
            case KeyEvent.VK_ENTER:
                // GameWindow gameWindow = new GameWindow();
                // gameWindow.startFrame();
                break;
            case KeyEvent.VK_J:
                // GameWindow gameWindow1 = new GameWindow();
                // gameWindow1.startFrame();
                break;
        }
    }
}